<?php

// Remove default widgets
function remove_dashboard_widgets() {
	global $wp_meta_boxes;
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );


// Remove Admin Menu
function remove_menus () {
	global $menu;
	$restricted = array();
	//$restricted = array( __('Dashboard'), __('Comments'), __('Tools') );
	end ($menu);
	while ( prev($menu) ) {
		$value = explode( ' ',$menu[key($menu)][0] );
		if( in_array( $value[0] != NULL ? $value[0] : '', $restricted ) ) { unset( $menu[key($menu)] ); }
	}
	
	// Remove submenus
	remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' );
	remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' );
	remove_submenu_page( 'themes.php', 'customize.php' );
}
add_action('admin_menu', 'remove_menus');

// Hide Welcome Panel
function hide_welcome_panel() {
	$user_id = get_current_user_id();
	if ( 1 == get_user_meta( $user_id, 'show_welcome_panel', true ) )
		update_user_meta( $user_id, 'show_welcome_panel', 0 );
}
add_action( 'load-index.php', 'hide_welcome_panel' );

// Remove Sub Menu
function remove_submenu() {
	remove_submenu_page( 'options-general.php', 'options-privacy.php' );  // main-menu-slug, sub-menu-sug
	remove_submenu_page( 'themes.php', 'widgets.php' );
}
//add_action('admin_init','remove_submenu');

//  Remove Post Edit Page Blocks
function customize_meta_boxes() {
	remove_meta_box('categorydiv','post','normal');
	// remove_meta_box('tagsdiv-post_tag','post','normal');
	// remove_meta_box('slugdiv','post','normal');
	//remove_meta_box('postimagediv','post','normal');
	remove_meta_box('postexcerpt','post','normal');
	remove_meta_box('formatdiv','post','normal');
	remove_meta_box('trackbacksdiv','post','normal');
	remove_meta_box('postcustom','post','normal');
	// remove_meta_box('commentstatusdiv','post','normal');
	// remove_meta_box('commentsdiv','post','normal');
	remove_meta_box('authordiv','post','normal');
	// remove_meta_box('revisionsdiv','post','normal');

	// remove_meta_box('slugdiv','page','normal');
	remove_meta_box('postimagediv','page','normal');
	remove_meta_box('postexcerpt','page','normal');
	remove_meta_box('formatdiv','page','normal');
	remove_meta_box('trackbacksdiv','page','normal');
	remove_meta_box('postcustom','page','normal');
	remove_meta_box('commentstatusdiv','page','normal');
	remove_meta_box('commentsdiv','page','normal');
	remove_meta_box('authordiv','page','normal');
	remove_meta_box('revisionsdiv','page','normal');
}
add_action('admin_init','customize_meta_boxes');

// Remove Items from the Post and Page Columns
function custom_post_columns($defaults) {
	unset($defaults['comments']);
	unset($defaults['tags']);
	unset($defaults['categorys']);
	return $defaults;
}
function custom_pages_columns($defaults) {
	unset($defaults['comments']);
	return $defaults;
}
add_filter('manage_posts_columns', 'custom_post_columns');
add_filter('manage_pages_columns', 'custom_pages_columns');

// add post type class to body admin
function sld_admin_body_class( $classes ) {
	global $wpdb, $post;
	$post_type = get_post_type( $post->ID );
	if ( is_admin() ) {
		$classes .= 'type-' . $post_type;
	}
	return $classes;
}
add_filter( 'admin_body_class', 'sld_admin_body_class' );

// Make large size be selected by default in media upload window
function make_full_size_be_selected_by_default(){
	update_option('image_default_size', 'full');
}
add_action( 'after_setup_theme', 'make_full_size_be_selected_by_default' ); 

// Clear Header
function clear_header() {
	echo '
	<style type="text/css" media="screen">
		#wp-admin-bar-wp-logo,
		#wp-admin-bar-comments,
		#wp-admin-bar-new-content,
		#wp-admin-bar-updates,
		#wpfooter,
		#menu-comments,
		#menu-media,
		#menu-plugins,

		li#toplevel_page_edit-post_type-cfs,
		tr#contact-form-7,
		tr#custom-field-suite,
		tr#really-simple-captcha,
		tr#contact-form-db,
		tr#twitget,
		
		li#toplevel_page_edit-post_type-acf,
		tr#wpml-translation-management,
		tr#wpml-string-translation,
		tr#wpml-multilingual-cms,
		tr#intuitive-custom-post-order,
		tr#codestyling-localization,
		tr#ambrosite-nextprevious-post-link-plus,
		tr#advanced-custom-fields-repeater-field,
		tr#advanced-custom-fields,
		tr#admin-menu-editor,

		#contextual-help-link-wrap{
			display: none;
		}
	</style>';
}
// add_action( 'admin_head', 'clear_header' );

// Custom css
function custom_css() {
	echo '
	<style type="text/css" media="screen">
		 #postimagediv{
			/*display: none;*/
		 }
	</style>';
}
add_action( 'admin_head', 'custom_css' );

// Custom javascript
function of_javascript(){
	echo 
	'<script type="text/javascript">
		jQuery(document).ready( function() {
			
		} )
	</script>';
}
// add_action('admin_head', 'of_javascript');

